﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;

using Finance.Entites;
using Finance.UI.ViewModels;

namespace Finance.UI.ConfigPages
{
    public partial class PayoutClassificationConfig : PhoneApplicationPage
    {
        public PayoutClassificationConfig()
        {
            InitializeComponent();
            Loaded += (o, e) => InilizeDataContext();
        }

        private void InilizeDataContext()
        {
            var dataContext = new SettingPageViewModel();

            var groups = App.PayoutClassificationDataStore.Items.Select(item => item.Group).Distinct();
            foreach (var group in groups)
            {
                dataContext.ConfigGroups.Add(new SettingDisplayItemViewModel()
                {
                    CurrentConfigItemName = group,
                    SetConfigPageUri = "/ConfigPages/SubPayoutClassificationConfig.xaml?subType=" + group
                });
            }

            this.DataContext = dataContext;
        }

        private void abibSave_Click(object sender, EventArgs e)
        {
            //TODO: Save config action
            NavigationService.Navigate(new Uri("/AccountSettingPage.xaml", UriKind.RelativeOrAbsolute));
        }

        private void abibBack_Click(object sender, EventArgs e)
        {
            NavigationService.Navigate(new Uri("/AccountSettingPage.xaml", UriKind.RelativeOrAbsolute));
        }
    }
}